package com.gxa.employment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gxa.employment.entity.pojo.Permission;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;


/**
 * <p>
 * 系统权限表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-03-25
 */
public interface PermissionMapper extends BaseMapper<Permission> {
    //单独查询该角色的  可访问的url
    @Select("SELECT perm_url FROM v_manager_permission WHERE manager_id = #{managerId} AND perm_type=#{type}")
    Set<String> selectUrlById(@Param("managerId")Integer managerId,@Param("type") String type);

    //单独查询该角色的  菜单列表
    @Select("SELECT perm_remark,perm_id,perm_pid,perm_type,perm_url FROM v_manager_permission WHERE manager_id = #{managerId} AND perm_type='菜单'")
    List<Permission> selectMenuById(Integer managerId);

    //查询该权限的子权限id  删除所有非父级id的  权限表中没他的pid的权限
    @Select(" SELECT perm_id FROM tb_permission WHERE perm_pid =#{id}")
    List<Integer> selectChildId(Integer id);

    //删除所有没有父级id的权限
    Integer batchDelete(@Param("list") List<Integer> list);

    //批量删除角色权限表的数据  不需要判断角色
    Integer batchDeleteByRole(@Param("list") List<Integer> list);
}
